<script type="text/javascript" src="<?=BASE_URL();?>java_scripts/vote_scripts.js"></script>
<div>
<?php 
	$error_msg=(!isset($error))?"":$error;
?>
   <table border="0" width="100%">
      <tr>
      	<td style="font-size: 20px;font-weight: bold;">Add New - Vote Item</td>
      </tr>
      <tr>
      	<td align="center">
	      	<form action="" method="post">
	      		<table border="0" cellpadding="0" cellspacing="0" width="80%">
	      			<?php 
		      			foreach($items->result_array() as $item){
		      			$id=(!isset($error))?$item['vote_item_id']:$item_id;
		      			$desc=(!isset($error))?$item['vote_item_desc']:$item_desc;
		      			$cat_id=(!isset($error))?$item['vote_item_cat_id']:$cat_id;
	      			?>
	      			<tr align="center">
	      				<td height="55" align="right">
		      				<input type="hidden" name="txtitemid" value="<?=$id?>">
		      				Item Name :&nbsp;&nbsp;&nbsp;
	      				</td>
	      				<td align="left"><input type="text" value="<?=$desc?>" name="txtitem" id="txtitem" maxlength="255" style="width: 250px;" /><div id='existing'><?=$error_msg?></div></td>
	      			</tr>
	      			<tr align="center">
	      				<td height="25" align="right">Category :&nbsp;&nbsp;&nbsp;</td>
	      				<td align="left">
	      				<select name="txtcat" id="txtcat">
	      					<?php 
	      					foreach($categories->result_array() as $category){
	      						$selectme=($cat_id==$category['vote_item_cat_id'])?"selected":"";
	      					?>
	      					<option value="<?=$category['vote_item_cat_id']?>" <?=$selectme?>><?=$category['vote_item_cat_desc']?></option>
	      					<?php 
	      						}
	      					?>
	      				</select>
	      				</td>
	      			</tr>
	      			<tr align="center">
	      				<td>&nbsp;</td>
	      				<td height="20" colspan="2" align="left"><br/><input type="button" class="button_back_end" onclick="javascript:window.location='<?=site_url("vote_management/voteItem")?>'" style="cursor: pointer;" value="Back"/><input type="button" class="button_back_end" onclick="javascript:updateItem('<?=site_url("vote_management/updateItem")?>')" style="cursor: pointer;" value="Update"/></td>
	      			</tr>
	      			<?php 
		      			}
	      			?>
	      		</table>
	      	</form>
      	</td>
      </tr>
   </table>
</div>
